package com.example.expandablelistview.thread;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.TextView;

import com.example.expandablelistview.R;

public class Handler_DivideEx extends Activity {
	private int mMainValue;
	private TextView mMainTv;
	private TextView mBackTv;
	private BackThread mThread;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.handlerex);

		mMainTv = (TextView) findViewById(R.id.m_main_value);
		mBackTv = (TextView) findViewById(R.id.m_back_value);

		mThread = new BackThread(mHandler);
		mThread.setDaemon(true);
		mThread.start();
	}

	public void mOnClick(View v) {
		mMainValue++;
		mMainTv.setText(String.format(getResources().getString(R.string.subTitle_thread_handler_mainValue), mMainValue));
	}

	Handler mHandler = new Handler() {
		public void handleMessage(Message msg) {
			if (msg.what == 0) mBackTv.setText(String.format(getResources().getString(R.string.subTitle_thread_handler_backValue), msg.arg1));
		}
	};

}
